<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录页</title>
    <link rel="stylesheet" href="./vendor/simple-line-icons/css/simple-line-icons.css">
    <link rel="stylesheet" href="./vendor/font-awesome/css/fontawesome-all.min.css">
    <link rel="stylesheet" href="./css/styles.css">
    <script src="./js/common.js"></script>
</head>
<body style="background: url(imgs/nimages/timg.jpg) no-repeat center top;">
<div class="page-wrapper flex-row align-items-center">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-5">
                <div class="card p-4">
                    <div class="card-header text-center text-uppercase h4 font-weight-light">
                        登录
                    </div>

                    <div class="card-body py-5">
                        <div class="form-group">
                            <label class="form-control-label">账号</label>
                            <input id="login_name" type="email" class="form-control">
                        </div>

                        <div class="form-group">
                            <label class="form-control-label">密码</label>
                            <input id="login_code" type="password" class="form-control">
                        </div>
                    </div>

                    <div class="card-footer">
                        <div class="row">
                            <div class="col-12" style="text-align: center">
                                <button id="login_submit" type="submit" class="btn btn-primary px-5">登录</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="./vendor/jquery/jquery.min.js"></script>
<script>
    $("#login_submit").on('click', function(){
        var name = $("#login_name").val();
        var code = $("#login_code").val();
        if(name == ""){
            $("#login_name").focus();
            alert("请输入账号");
        }else if(code == ""){
            $("#login_code").focus();
            alert("请输入密码");
        }else{
            $.ajax({
                url: "/sjgl/user/login",
                type: "POST",
                data: {
                    "login" : name,
                    "password" : code
                },
                dataType: "json",
                error: function () {
                    debugger;
                },
                success: function (data, status) { //如果调用php成功
                   if(data){
                       window.location = "index.html";
                   }else{
                       alert("账号密码错误");
                   }
                }
            });
        }

    });
    
	$(this).keydown(function (e){
		if(e.which == "13"){
			$("#login_submit").click();
	  	}
    });
</script>
<!-- <script src="./js/carbon.js"></script>
<script src="./js/demo.js"></script> -->
</body>
</html>
